<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../css/iuapmobile.um.css">
		<link rel="stylesheet" href="../css/font-icons.css">
		<link rel="stylesheet" type="text/css" href="../css/iuapmobile.um.listview.css">

		<style>
			.listview-detail {
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
			}

		</style>

		<script src="../js/summer.js" ></script>
		<script src="../js/jquery.min.js" ></script>
		<script src="../js/Frameworks/iuapmobile.frameworks.ui.js" ></script>
		<script type="text/javascript" src="../js/knockout.js"></script>
		<script type="text/javascript" src="../js/Frameworks/iuapmobile.frameworks.listview.js"></script>
	</head>
	<body class="f14">
		<div class="um-win" id="indexs">
			<div class="um-header" >
				<h3>设备签收</h3>
				<a href="#" class="um-back back">返回</a>
			</div>

			<div class="um-content">
				<div class="um-listview-wrap" id="listview">
					<div class="hd1 pt15 pb15 f15" style="text-align: center;display: none">
						<span class="ti-reload">没有找到数据 点击刷新</span>
					</div>
					<ul class="um-list um-no-active" data-bind="foreach:data">
						<li class="um-listview-row">
							<a href="#" class="um-list-item um-swipe-action um-no-icon">
							<div class="um-list-item-inner">
								<div class="um-list-item-body um-text-overflow f14" style="padding-right:5px;">
									<div class="um-bgc-blue um-white pt5 pb5 ">
										︱设备编号:<span data-bind="text:deviceid"></span>
									</div>
									<div class="w">
										<div class="um-md-6 w_50 fl mt10 mb10">
											品牌:<span data-bind="text:brand"></span>
										</div>
										<div class="um-md-6 w_50 fl mt10 mb10">
											物料信息:<span data-bind="text:materialinformation"></span>
										</div>
									</div>
									<div class="w">
										<!--<div class="um-md-6 w_50 fl mt10 mb10">
											设备签收人:<span data-bind="text:receiver"></span>
										</div>
										<div class="um-md-6 w_50 fl mt10 mb10">
											吊装支架数量:<span data-bind="text:hoistingcount"></span>
										</div>
										<div class="um-md-6 w_50 fl mt10 mb10">
											提货数量:<span data-bind="text:isNeedExtendevice"></span>
										</div>-->
									</div>
									<!--<div class="w">
										
									</div>-->

								</div>
							</div> </a>
						</li>
					</ul>
				</div>
			</div>

			<div class="um-footer">
				<div class="um-box">
					<button class="btns" onclick="submitlist()">
						确认签收
					</button>
				</div>
			</div>
		</div>

		<script type="text/javascript">
			var init;
			var billid;
			var ic_material_id;
			var remainingCount;
			$(function() {
				var ViewModel = function() {
				};
				var pageIndex = 1;
				var qainlist = [];
				var viewModel = new ViewModel();
				var listview = UM.listview("#listview");
				viewModel.data = ko.observableArray([]);
				ko.applyBindings(viewModel);
				//绑定叶号，是否第一次bool
				init = function(index, cout) {
					doPost(adressHead.ISjtzImpl, "getEquipmentReceipt_V2", {
						dataParm : {
							empId : summer.getStorage('userinfo').empId,
							billid :billid
						}
					}, function(data) {
						if (index == 1) {
							try {
								while (viewModel.data.shift()) {
								}
							} catch(e) {
							}
						};
						if (data.result == 1) {
							if (data.data.length != "") {
							    ic_material_id = data.data[0].ic_material_id;
								for (var i = 0; i < data.data.length; i++) {
									console.log("aaaa" + data.data[i]);
									viewModel.data.push({
										'deviceid' : data.data[i].deviceid,
										'brand' : data.data[i].brand,
										'materialinformation' : data.data[i].materialinformation,
										'receiver' : data.data[i].receiver,
										'isNeedExtendevice' : data.data[i].isneedextendevice,
										'hoistingcount' : data.data[i].hoistingcount,
										'ic_material_id':data.data[i].ic_material_id
									});
								};
								pageIndex += data.data.length;
							} else {
								UM.toast({
									title : '友情提示：',
									text : '没有更多单据',
									duration : 1000
								});
								$("initdiv").css("display", "block");
							}
						} else {
							UM.toast({
								title : '友情提示：',
								text : data.msg,
								duration : 1000
							});
						}
						listview.refresh();
					}, function(err) {
						console.log(err);
					});
				};
				$(".hd1").click(function(e) {
					init(1, 4);
					e.stopPropagation(); 
				});
				//构造控件实例
				var listview = UM.listview("#listview");
				//添加控件方法
				listview.on("pullDown", function(sender) {
					pageIndex = 1;
					init(pageIndex, 4);
					sender.refresh();
				});
				listview.on("pullUp", function(sender) {
					init(pageIndex, 4);
					sender.refresh();
				});
				listview.on("itemClick", function(sender, args) {
					//alert(args.rowIndex);
					//这里可以处理行点击事件，参数sender即为当前列表实例对象，args对象有2个属性，即rowIndex(行索引)和$target(目标行的jquery对象)
					//alert("您点击了列表的第" + (args.rowIndex + 1) +　"行！");
				});

			});
			function submitlist() {
				doPost(adressHead.ISjtzImpl, "ConfirmEquipmentReceipt_V2", {
					dataParm : {
						empId : summer.getStorage('userinfo').empId,
						billid : billid,
						ic_material_id:ic_material_id,
						remainingCount:remainingCount,
						status : 4
					}
				}, function(data) {
						UM.toast({
							title : '友情提示：',
							text : data.msg || JSON.stringify(data),
							duration : 1000
						});
					if (data.result == 1) {
						setTimeout(function(){
						summer.execScript({
						    winId: 'qianshoulist',
						    script: "rebind()"
						});
						summer.closeWin();
						},1000);
					}
				}, function(err) {
					UM.toast({
							title : '友情提示：',
							text : err.msg,
							duration : 1000
						});
				})
			}

			summerready = function() {
				if (summer.pageParam) {
					billid = summer.pageParam.billid;
					remainingCount = summer.pageParam.remainingCount;
					init(1, 4);
				}
			}
		</script>
	</body>
</html>
<script type="text/javascript" src="../js/Myjs/Common.js"></script>